public class Field {

	private int field_id;

	private Field north;
	private Field east;
	private Field south;
	private Field west;
	private Barrier b_north;
	private Barrier b_east;
	private Barrier b_south;
	private Barrier b_west;

	public Field(Field _north, Field _east, Field _south, Field _west) {
		field_id = Field_ID.get_id();
		north = _north;
		east = _east;
		south = _south;
		west = _west;

	}

	public Field() {
		field_id = Field_ID.get_id();
		this.north = null;
		this.east = null;
		this.south = null;
		this.west = null;

	}

	public void set_north(Field o, Barrier b) {
		b_north = b;
		this.north = (o == null) ? null : o;
		if (o != null && o.get_south() == null) {
			o.set_south(this, b);
		}
	}

	public void set_east(Field o, Barrier b) {
		b_east = b;
		this.east = (o == null) ? null : o;
		if (o != null && o.get_west() == null) {
			o.set_west(this, b);
		}
	}

	public void set_south(Field o, Barrier b) {
		b_south = b;
		this.south = (o == null) ? null : o;
		if (o != null && o.get_north() == null) {
			o.set_north(this, b);
		}
	}

	public void set_west(Field o, Barrier b) {
		b_west = b;
		this.west = (o == null) ? null : o;
		if (o != null && o.get_east() == null) {
			o.set_east(this, b);
		}
	}

	public int get_id() {
		return field_id;
	}

	public Field get_north() {
		return north;
	}

	public Field get_east() {
		return east;
	}

	public Field get_south() {
		return south;
	}

	public Field get_west() {
		return west;
	}

	public Barrier get_b_north() {
		return b_north;
	}

	public Barrier get_b_east() {
		return b_east;
	}

	public Barrier get_b_south() {
		return b_south;
	}

	public Barrier get_b_west() {
		return b_west;
	}

	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("----------------------------------\n");
		sb.append("Field: " + get_id());
		sb.append("\nIn the ..");
		sb.append("\nNorth is Field " + get_north() + ", Barrier: " + get_b_north());
		sb.append("\nEast is Field " + get_east() + ", Barrier: " + get_b_east());
		sb.append("\nSouth is Field " + get_south() + ", Barrier: " + get_b_south());
		sb.append("\nWest is Field " + get_west() + ", Barrier: " + get_b_west());
		sb.append("\n----------------------------------");
		
		return sb.toString();
				
				
				
				
	}
}
